Intro

Who am I?

  • dr. Uros Godnov
  • Born 1975
  • 20+ years experiences in programming, database design and BI
  • Data scientist
  • MCP, MCSA MS SQL 2012/2014, VBA, Python, R
  • email: uros.godnov@gmail.com
  • github:https://github.com/urosgodnov

What I mostly do

About data science

About data science and R

About data science and R

About R

  • R is open source and free
  • maintained by Comprehensive R Archive Network (CRAN) site at https://cran.r-project.org/

About R

  • 22 years from the release of R v1.0.0
  • principles behind R are actually much older than 20 years and even 40 years

About R

  • https://cran.r-project.org/
  • Packages contain functions
  • On 5. 4. 2017 there were 10.396 packages
  • Currently (21. 01. 2024) there are  20.304  packages
  • http://www.r-pkg.org/
  • IDE Rstudio:
    • Intellisense
    • Markdown
    • Quarto
    • Notebooks
    • Debugging . . .
  • Rstudio cheat sheets https://posit.co/resources/cheatsheets/

About R

About R

Types of programming

  • procedural
  • object oriented
  • functional

Procedural

factorial <- function(n) {
  result <- 1
  if (n > 1) {
    for (i in 2:n) {
      result <- result * i
    }
  }
  return(result)
}

# Calling the function
number <- 5

cat(number, "factorial is", factorial(number))
5 factorial is 120

Object-oriented

setClass(
  "Circle",
  slots = list(radius = "numeric")
)
Circle <- function(radius) {
  new("Circle", radius = radius)
}
# Define a generic function for area
setGeneric("area", function(x) standardGeneric("area"))
[1] "area"
# Define the method for calculating the area of a Circle
setMethod("area", "Circle", function(x) {
  pi * slot(x, "radius")^2
})
# Define a generic function for circumference
setGeneric("circumference", function(x) standardGeneric("circumference"))
[1] "circumference"
# Define the method for calculating the circumference of a Circle
setMethod("circumference", "Circle", function(x) {
  2 * pi * slot(x, "radius")
})
# Create a Circle object
circle <- Circle(5)

cat("The area of the circle is", area(circle), "\n")
The area of the circle is 78.53982 
cat("The circumference of the circle is", circumference(circle))
The circumference of the circle is 31.41593

Functional programming

# Functional Programming Example: Using purrr to operate on lists

# Load purrr for functional programming
library(purrr)

# A list of numbers
numbers <- list(1, 2, 3, 4, 5)

# Define a function to square a number
square <- function(x) {
  return(x^2)
}

# Use map to apply the square function to each element of the list
squared_numbers <- map(numbers, square)

# Print the result
cat("Squared numbers:", unlist(squared_numbers))
Squared numbers: 1 4 9 16 25

IDE

  • RStudio
  • VS Code
  • Visual studio
  • Atom

RStudio

  • https://www.rstudio.com/ –> https://posit.co/downloads/
  • on line version of RStudio: https://rstudio.cloud/ –> https://posit.cloud/content/yours?sort=name_asc
  • Google Colab

Git - you can optinally install it

  • An open-source version control system
  • preferred version control system of most developers
  • others delta-based version control
  • Git thinks about its data more like a stream of snapshots
  • git

Github - register

  • the center around which all things involving Git revolve is the hub
  • free/pro
  • mind the bandwidth
  • great for your portfolio